package com.xx566.blog.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.xx566.blog.model.Message;
import com.xx566.blog.model.User;

/**
 * BlogValidator.
 */
public class XX566Validator extends Validator {

	protected void validate(Controller controller) {
		validateRequiredString("user.name", "nameMsg", "请输入您的姓名");
		validateRequiredString("user.email", "emailMsg", "请输入您的邮箱");
	}

	protected void handleError(Controller controller) {
		controller.keepModel(User.class);
		controller.keepModel(Message.class);
		int artid = controller.getParaToInt("message.articleid");
		controller.redirect("/detail/"
				+ (artid < 0 ? ("n" + artid * (-1)) : artid));
	}
}
